Field of the Invention
The present invention generally relates to program execution preemption and more specifically to mid-primitive graphics program execution preemption.
Description of the Related Art
Preemption is a mechanism used to time-slice a processor between multiple different applications. One application executing during a first time-slice is preempted so that another application can execute during a second time-slice. When multiple different applications need to use the processor simultaneously, one way to achieve forward progress for all the applications is to run each application for a short time-slice on the processor. Conventionally, time slicing requires that the processor pipeline be completely drained, and, once the processor is idle, a different application is set up to be executed by the processor pipeline. This mechanism for time slicing has been referred to as “wait for idle” preemption and is particularly inefficient when the processor takes a long time to drain the work that is running on the processor pipeline. For example, consider a very long running graphics shader program, or in the worst case, a shader program with an infinite loop. To be able maintain processing performance when time slicing between different applications, the amount of time incurred to idle execution of each application should be limited or reduced as much as possible.
Another mechanism that has been considered to implement preemption is to stall or freeze the processor without draining the processor pipeline. Once the processor is frozen, the contents of all the registers and pipeline flip-flops within the processor that represent the execution state for a particular application are stored into dedicated registers. When execution of that particular application resumes, the contents of all of the registers and pipeline flip-flops stored in the dedicated registers are restored. One drawback of this approach to preemption is that the size of the execution state can be quite large, such that the time needed to store and restore the execution state reduces the time available for executing each of the applications during the time slices.
Accordingly, what is needed in the art is a more effective approach to execution preemption.